package com.hundredapp.oa.repository;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.hundredapp.oa.dao.GenericDao;
import com.hundredapp.oa.dao.SelectType;
import com.hundredapp.oa.domain.OaRoleService;
import com.hundredapp.oa.domain.OaService;

@Repository
public class ServiceManagerImpl implements ServiceManager {
	
	@Autowired
	private GenericDao<OaRoleService, Integer> roleServiceDao;
	@Autowired
	private GenericDao<OaService,Integer> serviceDao;

	@Override
	public OaRoleService findRoleService(int roleId, int serviceid) {
		OaRoleService result=roleServiceDao.findUnique(String.format("roleId=%s and serviceId=%s", roleId,serviceid));
		return result;
	}
	
	@Override
	public List<OaService> findAll(){
		return serviceDao.find(SelectType.SELECT_ALL);
	}
	
	@Override
	public void saveOrUpdate(OaRoleService roleService){
		roleServiceDao.saveOrUpdate(roleService);
	}

	public void setRoleServiceDao(GenericDao<OaRoleService, Integer> roleServiceDao) {
		this.roleServiceDao = roleServiceDao;
	}

	public void setServiceDao(GenericDao<OaService, Integer> serviceDao) {
		this.serviceDao = serviceDao;
	}

}
